package com.winning.devops.cloud.id.time;

import java.util.Calendar;

/**
 * 时间服务接口
 *
 * @author chensj@winning.com.cn
 */
public interface TimeService {

    int FIRST_DAY_OF_WEEK = Calendar.MONDAY;

    int MINUTE = Calendar.MINUTE;

    int HOUR = Calendar.HOUR;

    int DAY = Calendar.DAY_OF_MONTH;

    int WEEK = Calendar.WEEK_OF_MONTH;

    int MONTH = Calendar.MONTH;

    int YEAR = Calendar.YEAR;

    /**
     * 判断是否需要切换主键生成，即主键从头开始
     * @param calField 时间类型
     * @param oldTimeInMillis 对比值，时间的毫秒值(long)
     * @return boolean
     */
    boolean isCutoff(int calField, long oldTimeInMillis);

    /**
     * 判断是否需要切换主键生成，即主键从头开始
     * @param calField 时间类型
     * @param currentTimeMillis 当前时间的毫秒值
     * @param oldTimeInMillis 旧的时间的毫秒值
     * @return boolean
     */
    boolean isCutoff(int calField, long currentTimeMillis,
                     long oldTimeInMillis);

    /**
     * 当前时间的毫秒值
     * @return long
     */
    long currentTimeMillis();
}
